from typing import List
import sys

def LMI() -> List[int]:
    """Read multiple integers from input"""
    return list(map(int, input().split()))

def LMF() -> List[float]:
    """Read multiple floats from input"""
    return list(map(float, input().split()))

def LI(n: int) -> List[str]:
    """Read n strings from input"""
    return [input() for _ in range(n)]

def RIM(rows: int, cols: int) -> List[List[int]]:
    """Read a matrix of integers"""
    return [LMI() for _ in range(rows)]

def MII():
    """Read multiple integers from input as a map"""
    return map(int, sys.stdin.readline().split())

def II():
    """Read a single integer from input"""
    return int(sys.stdin.readline())

def FI():
    """Read a single float from input"""
    return float(sys.stdin.readline())


        
def solve() -> None:
    try:
        w,m,n = MII()
        row_m = m//w + (m%w!=0)
        row_n = n//w + (n%w!=0)
        col_m = w-m%w+1 if row_m%2==0 else m%w
        col_n = w-n%w+1 if row_n%2==0 else n%w
        # print("row_m=",row_m,"col_m=",col_m)
        # print("row_n=",row_n,"col_n=",col_n)
        print(abs(row_m-row_n)+abs(col_m-col_n))
        
    except (EOFError, KeyboardInterrupt):
        pass

# =============================================================================
# MAIN EXECUTION
# =============================================================================

if __name__ == "__main__":
    # For multiple test cases, uncomment:
    # t = int(input())
    # for _ in range(t):
    #     solve()
    
    # For single test case:
    solve()
# 